package com.example.bysj.Service;
//201902104061徐中堂
import com.example.bysj.Dao.RoleDao;
import com.example.bysj.domain.authority.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
//声明一个业务处理类
@Service("roleService")
//@Transactional注解：可以用在方法上和类上，用在类上代表这个类的所有公共非静态方法都将启用事务功能。
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation. REQUIRED)
public class RoleService {
    @Autowired
    private RoleDao roleDao;

    //添加
    public Boolean add(Role role){
        return roleDao.add(role);
    }
    //根据id查找
    public Role find(int id){
        Role role = roleDao.getRoleById(id);
        return role;
    }
    //查找全部
    public List<Role> findAll(){
        List<Role> roles = roleDao.findAll();
        return roles;
    }
    //修改
    public Boolean update(Role role){
        return roleDao.update(role);
    }
    //删除
    public Boolean delete(int id){
        return roleDao.delete(id);
    }
}

